 /*
 * MikoPBX - free phone system for small business
 * Copyright © 2017-2023 Alexey Portnov and Nikolay Beketov
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program.
 * If not, see <https://www.gnu.org/licenses/>.
 */ /*
 * # Fomantic UI - 2.7.2
 * https://github.com/fomantic/Fomantic-UI
 * http://fomantic-ui.com/
 *
 * Copyright 2014 Contributors
 * Released under the MIT license
 * http://opensource.org/licenses/MIT
 *
 */
!function(G,J,Z,_){"use strict";G.isFunction=G.isFunction||function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},J=void 0!==J&&J.Math==Math?J:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),G.fn.dropdown=function(N){var H,j=G(this),U=G(Z),B=j.selector||"",K="ontouchstart"in Z.documentElement,W=(new Date).getTime(),Y=[],$=N,Q="string"==typeof $,X=[].slice.call(arguments,1);return j.each(function(n){var e,t,i,a,o,s,r,h,m=G.isPlainObject(N)?G.extend(!0,{},G.fn.dropdown.settings,N):G.extend({},G.fn.dropdown.settings),g=m.className,c=m.message,l=m.fields,p=m.keys,b=m.metadata,u=m.namespace,d=m.regExp,w=m.selector,v=m.error,f=m.templates,x="."+u,C="module-"+u,y=G(this),S=G(m.context),A=y.find(w.text),T=y.find(w.search),k=y.find(w.sizer),L=y.find(w.input),I=y.find(w.icon),D=y.find(w.clearIcon),q=0<y.prev().find(w.text).length?y.prev().find(w.text):y.prev(),R=y.children(w.menu),O=R.find(w.item),E=m.hideDividers?O.parent().children(w.divider):G(),V=!1,M=!1,F=!1,z=this,P=y.data(C);h={initialize:function(){h.debug("Initializing dropdown",m),h.is.alreadySetup()?h.setup.reference():(m.ignoreDiacritics&&!String.prototype.normalize&&(m.ignoreDiacritics=!1,h.error(v.noNormalize,z)),h.setup.layout(),m.values&&h.change.values(m.values),h.refreshData(),h.save.defaults(),h.restore.selected(),h.create.id(),h.bind.events(),h.observeChanges(),h.instantiate())},instantiate:function(){h.verbose("Storing instance of dropdown",h),P=h,y.data(C,h)},destroy:function(){h.verbose("Destroying previous dropdown",y),h.remove.tabbable(),y.off(x).removeData(C),R.off(x),U.off(a),h.disconnect.menuObserver(),h.disconnect.selectObserver()},observeChanges:function(){"MutationObserver"in J&&(s=new MutationObserver(h.event.select.mutation),r=new MutationObserver(h.event.menu.mutation),h.debug("Setting up mutation observer",s,r),h.observe.select(),h.observe.menu())},disconnect:{menuObserver:function(){r&&r.disconnect()},selectObserver:function(){s&&s.disconnect()}},observe:{select:function(){h.has.input()&&s.observe(y[0],{childList:!0,subtree:!0})},menu:function(){h.has.menu()&&r.observe(R[0],{childList:!0,subtree:!0})}},create:{id:function(){o=(Math.random().toString(16)+"000000000").substr(2,8),a="."+o,h.verbose("Creating unique id for element",o)},userChoice:function(e){var n,i,a;return!!(e=e||h.get.userValues())&&(e=Array.isArray(e)?e:[e],G.each(e,function(e,t){!1===h.get.item(t)&&(a=m.templates.addition(h.add.variables(c.addResult,t)),i=G("<div />").html(a).attr("data-"+b.value,t).attr("data-"+b.text,t).addClass(g.addition).addClass(g.item),m.hideAdditions&&i.addClass(g.hidden),n=n===_?i:n.add(i),h.verbose("Creating user choices for value",t,i))}),n)},userLabels:function(e){var t=h.get.userValues();t&&(h.debug("Adding user labels",t),G.each(t,function(e,t){h.verbose("Adding custom user value"),h.add.label(t,t)}))},menu:function(){R=G("<div />").addClass(g.menu).appendTo(y)},sizer:function(){k=G("<span />").addClass(g.sizer).insertAfter(T)}},search:function(e){e=e!==_?e:h.get.query(),h.verbose("Searching for query",e),h.has.minCharacters(e)?h.filter(e):h.hide()},select:{firstUnfiltered:function(){h.verbose("Selecting first non-filtered element"),h.remove.selectedItem(),O.not(w.unselectable).not(w.addition+w.hidden).eq(0).addClass(g.selected)},nextAvailable:function(e){var t=(e=e.eq(0)).nextAll(w.item).not(w.unselectable).eq(0),n=e.prevAll(w.item).not(w.unselectable).eq(0);0<t.length?(h.verbose("Moving selection to",t),t.addClass(g.selected)):(h.verbose("Moving selection to",n),n.addClass(g.selected))}},setup:{api:function(){var e={debug:m.debug,urlData:{value:h.get.value(),query:h.get.query()},on:!1};h.verbose("First request, initializing API"),y.api(e)},layout:function(){y.is("select")&&(h.setup.select(),h.setup.returnedObject()),h.has.menu()||h.create.menu(),h.is.selection()&&h.is.clearable()&&!h.has.clearItem()&&(h.verbose("Adding clear icon"),D=G("<i />").addClass("remove icon").insertBefore(A)),h.is.search()&&!h.has.search()&&(h.verbose("Adding search input"),T=G("<input />").addClass(g.search).prop("autocomplete","off").insertBefore(A)),h.is.multiple()&&h.is.searchSelection()&&!h.has.sizer()&&h.create.sizer(),m.allowTab&&h.set.tabbable()},select:function(){var e=h.get.selectValues();h.debug("Dropdown initialized on a select",e),y.is("select")&&(L=y),0<L.parent(w.dropdown).length?(h.debug("UI dropdown already exists. Creating dropdown menu only"),y=L.closest(w.dropdown),h.has.menu()||h.create.menu(),R=y.children(w.menu),h.setup.menu(e)):(h.debug("Creating entire dropdown from select"),y=G("<div />").attr("class",L.attr("class")).addClass(g.selection).addClass(g.dropdown).html(f.dropdown(e,m.preserveHTML,m.className)).insertBefore(L),L.hasClass(g.multiple)&&!1===L.prop("multiple")&&(h.error(v.missingMultiple),L.prop("multiple",!0)),L.is("[multiple]")&&h.set.multiple(),L.prop("disabled")&&(h.debug("Disabling dropdown"),y.addClass(g.disabled)),L.removeAttr("class").detach().prependTo(y)),h.refresh()},menu:function(e){R.html(f.menu(e,l,m.preserveHTML,m.className)),O=R.find(w.item),E=m.hideDividers?O.parent().children(w.divider):G()},reference:function(){h.debug("Dropdown behavior was called on select, replacing with closest dropdown"),y=y.parent(w.dropdown),P=y.data(C),z=y.get(0),h.refresh(),h.setup.returnedObject()},returnedObject:function(){var e=j.slice(0,n),t=j.slice(n+1);j=e.add(y).add(t)}},refresh:function(){h.refreshSelectors(),h.refreshData()},refreshItems:function(){O=R.find(w.item),E=m.hideDividers?O.parent().children(w.divider):G()},refreshSelectors:function(){h.verbose("Refreshing selector cache"),A=y.find(w.text),T=y.find(w.search),L=y.find(w.input),I=y.find(w.icon),q=0<y.prev().find(w.text).length?y.prev().find(w.text):y.prev(),R=y.children(w.menu),O=R.find(w.item),E=m.hideDividers?O.parent().children(w.divider):G()},refreshData:function(){h.verbose("Refreshing cached metadata"),O.removeData(b.text).removeData(b.value)},clearData:function(){h.verbose("Clearing metadata"),O.removeData(b.text).removeData(b.value),y.removeData(b.defaultText).removeData(b.defaultValue).removeData(b.placeholderText)},toggle:function(){h.verbose("Toggling menu visibility"),h.is.active()?h.hide():h.show()},show:function(e){if(e=G.isFunction(e)?e:function(){},!h.can.show()&&h.is.remote()&&(h.debug("No API results retrieved, searching before show"),h.queryRemote(h.get.query(),h.show)),h.can.show()&&!h.is.active()){if(h.debug("Showing dropdown"),!h.has.message()||h.has.maxSelections()||h.has.allResultsFiltered()||h.remove.message(),h.is.allFiltered())return!0;!1!==m.onShow.call(z)&&h.animate.show(function(){h.can.click()&&h.bind.intent(),h.has.search()&&h.focusSearch(),h.set.visible(),e.call(z)})}},hide:function(e){e=G.isFunction(e)?e:function(){},h.is.active()&&!h.is.animatingOutward()&&(h.debug("Hiding dropdown"),!1!==m.onHide.call(z)&&h.animate.hide(function(){h.remove.visible(),h.is.focusedOnSearch()&&T.blur(),e.call(z)}))},hideOthers:function(){h.verbose("Finding other dropdowns to hide"),j.not(y).has(w.menu+"."+g.visible).dropdown("hide")},hideMenu:function(){h.verbose("Hiding menu  instantaneously"),h.remove.active(),h.remove.visible(),R.transition("hide")},hideSubMenus:function(){var e=R.children(w.item).find(w.menu);h.verbose("Hiding sub menus",e),e.transition("hide")},bind:{events:function(){K&&h.bind.touchEvents(),h.bind.keyboardEvents(),h.bind.inputEvents(),h.bind.mouseEvents()},touchEvents:function(){h.debug("Touch device detected binding additional touch events"),h.is.searchSelection()||h.is.single()&&y.on("touchstart"+x,h.event.test.toggle),R.on("touchstart"+x,w.item,h.event.item.mouseenter)},keyboardEvents:function(){h.verbose("Binding keyboard events"),y.on("keydown"+x,h.event.keydown),h.has.search()&&y.on(h.get.inputEvent()+x,w.search,h.event.input),h.is.multiple()&&U.on("keydown"+a,h.event.document.keydown)},inputEvents:function(){h.verbose("Binding input change events"),y.on("change"+x,w.input,h.event.change)},mouseEvents:function(){h.verbose("Binding mouse events"),h.is.multiple()&&y.on("click"+x,w.label,h.event.label.click).on("click"+x,w.remove,h.event.remove.click),h.is.searchSelection()?(y.on("mousedown"+x,h.event.mousedown).on("mouseup"+x,h.event.mouseup).on("mousedown"+x,w.menu,h.event.menu.mousedown).on("mouseup"+x,w.menu,h.event.menu.mouseup).on("click"+x,w.icon,h.event.icon.click).on("click"+x,w.clearIcon,h.event.clearIcon.click).on("focus"+x,w.search,h.event.search.focus).on("click"+x,w.search,h.event.search.focus).on("blur"+x,w.search,h.event.search.blur).on("click"+x,w.text,h.event.text.focus),h.is.multiple()&&y.on("click"+x,h.event.click)):("click"==m.on?y.on("click"+x,w.icon,h.event.icon.click).on("click"+x,h.event.test.toggle):"hover"==m.on?y.on("mouseenter"+x,h.delay.show).on("mouseleave"+x,h.delay.hide):y.on(m.on+x,h.toggle),y.on("mousedown"+x,h.event.mousedown).on("mouseup"+x,h.event.mouseup).on("focus"+x,h.event.focus).on("click"+x,w.clearIcon,h.event.clearIcon.click),h.has.menuSearch()?y.on("blur"+x,w.search,h.event.search.blur):y.on("blur"+x,h.event.blur)),R.on("mouseenter"+x,w.item,h.event.item.mouseenter).on("mouseleave"+x,w.item,h.event.item.mouseleave).on("click"+x,w.item,h.event.item.click)},intent:function(){h.verbose("Binding hide intent event to document"),K&&U.on("touchstart"+a,h.event.test.touch).on("touchmove"+a,h.event.test.touch),U.on("click"+a,h.event.test.hide)}},unbind:{intent:function(){h.verbose("Removing hide intent event from document"),K&&U.off("touchstart"+a).off("touchmove"+a),U.off("click"+a)}},filter:function(e){var t=e!==_?e:h.get.query(),n=function(){h.is.multiple()&&h.filterActive(),(e||!e&&0==h.get.activeItem().length)&&h.select.firstUnfiltered(),h.has.allResultsFiltered()?m.onNoResults.call(z,t)?m.allowAdditions?m.hideAdditions&&(h.verbose("User addition with no menu, setting empty style"),h.set.empty(),h.hideMenu()):(h.verbose("All items filtered, showing message",t),h.add.message(c.noResults)):(h.verbose("All items filtered, hiding dropdown",t),h.hideMenu()):(h.remove.empty(),h.remove.message()),m.allowAdditions&&h.add.userSuggestion(h.escape.htmlEntities(e)),h.is.searchSelection()&&h.can.show()&&h.is.focusedOnSearch()&&h.show()};m.useLabels&&h.has.maxSelections()||(m.apiSettings?h.can.useAPI()?h.queryRemote(t,function(){m.filterRemoteData&&h.filterItems(t);var e=L.val();Array.isArray(e)||(e=""!==e?e.split(m.delimiter):[]),G.each(e,function(e,t){O.filter('[data-value="'+t+'"]').addClass(g.filtered)}),n()}):h.error(v.noAPI):(h.filterItems(t),n()))},queryRemote:function(e,n){var t={errorDuration:!1,cache:"local",throttle:m.throttle,urlData:{query:e},onError:function(){h.add.message(c.serverError),n()},onFailure:function(){h.add.message(c.serverError),n()},onSuccess:function(e){var t=e[l.remoteValues];Array.isArray(t)||(t=[]),h.remove.message(),h.setup.menu({values:t}),0!==t.length||m.allowAdditions||h.add.message(c.noResults),n()}};y.api("get request")||h.setup.api(),t=G.extend(!0,{},t,m.apiSettings),y.api("setting",t).api("query")},filterItems:function(e){var i=h.remove.diacritics(e!==_?e:h.get.query()),a=null,t=h.escape.string(i),o=new RegExp("^"+t,"igm");h.has.query()&&(a=[],h.verbose("Searching for matching values",i),O.each(function(){var e,t,n=G(this);if("both"===m.match||"text"===m.match){if(-1!==(e=h.remove.diacritics(String(h.get.choiceText(n,!1)))).search(o))return a.push(this),!0;if("exact"===m.fullTextSearch&&h.exactSearch(i,e))return a.push(this),!0;if(!0===m.fullTextSearch&&h.fuzzySearch(i,e))return a.push(this),!0}if("both"===m.match||"value"===m.match){if(-1!==(t=h.remove.diacritics(String(h.get.choiceValue(n,e)))).search(o))return a.push(this),!0;if("exact"===m.fullTextSearch&&h.exactSearch(i,t))return a.push(this),!0;if(!0===m.fullTextSearch&&h.fuzzySearch(i,t))return a.push(this),!0}})),h.debug("Showing only matched items",i),h.remove.filteredItem(),a&&O.not(a).addClass(g.filtered),h.has.query()?!0===m.hideDividers?E.addClass(g.hidden):"empty"===m.hideDividers&&E.removeClass(g.hidden).filter(function(){var e=G(this).nextUntil(w.item);return 0===(e.length?e:G(this)).nextUntil(w.divider).filter(w.item+":not(."+g.filtered+")").length}).addClass(g.hidden):E.removeClass(g.hidden)},fuzzySearch:function(e,t){var n=t.length,i=e.length;if(e=e.toLowerCase(),t=t.toLowerCase(),n<i)return!1;if(i===n)return e===t;e:for(var a=0,o=0;a<i;a++){for(var s=e.charCodeAt(a);o<n;)if(t.charCodeAt(o++)===s)continue e;return!1}return!0},exactSearch:function(e,t){return e=e.toLowerCase(),-1<(t=t.toLowerCase()).indexOf(e)},filterActive:function(){m.useLabels&&O.filter("."+g.active).addClass(g.filtered)},focusSearch:function(e){h.has.search()&&!h.is.focusedOnSearch()&&(e?(y.off("focus"+x,w.search),T.focus(),y.on("focus"+x,w.search,h.event.search.focus)):T.focus())},blurSearch:function(){h.has.search()&&T.blur()},forceSelection:function(){var e=O.not(g.filtered).filter("."+g.selected).eq(0),t=O.not(g.filtered).filter("."+g.active).eq(0),n=0<e.length?e:t;0<n.length&&!h.is.multiple()?(h.debug("Forcing partial selection to selected item",n),h.event.item.click.call(n,{},!0)):(m.allowAdditions&&h.set.selected(h.get.query()),h.remove.searchTerm())},change:{values:function(e){m.allowAdditions||h.clear(),h.debug("Creating dropdown with specified values",e),h.setup.menu({values:e}),G.each(e,function(e,t){if(1==t.selected&&(h.debug("Setting initial selection to",t[l.value]),h.set.selected(t[l.value]),!h.is.multiple()))return!1})}},event:{change:function(){F||(h.debug("Input changed, updating selection"),h.set.selected())},focus:function(){m.showOnFocus&&!V&&h.is.hidden()&&!t&&h.show()},blur:function(e){t=Z.activeElement===this,V||t||(h.remove.activeLabel(),h.hide())},mousedown:function(){h.is.searchSelection()?i=!0:V=!0},mouseup:function(){h.is.searchSelection()?i=!1:V=!1},click:function(e){G(e.target).is(y)&&(h.is.focusedOnSearch()?h.show():h.focusSearch())},search:{focus:function(){V=!0,h.is.multiple()&&h.remove.activeLabel(),(m.showOnFocus||"focus"!==event.type)&&h.search()},blur:function(e){t=Z.activeElement===this,h.is.searchSelection()&&!i&&(M||t||(m.forceSelection&&h.forceSelection(),h.hide())),i=!1}},clearIcon:{click:function(e){h.clear(),h.is.searchSelection()&&h.remove.searchTerm(),h.hide(),e.stopPropagation()}},icon:{click:function(e){h.has.search()?h.is.active()?h.blurSearch():m.showOnFocus?h.focusSearch():h.toggle():h.toggle()}},text:{focus:function(e){V=!0,h.focusSearch()}},input:function(e){(h.is.multiple()||h.is.searchSelection())&&h.set.filtered(),clearTimeout(h.timer),h.timer=setTimeout(h.search,m.delay.search)},label:{click:function(e){var t=G(this),n=y.find(w.label),i=n.filter("."+g.active),a=t.nextAll("."+g.active),o=t.prevAll("."+g.active),s=0<a.length?t.nextUntil(a).add(i).add(t):t.prevUntil(o).add(i).add(t);e.shiftKey?(i.removeClass(g.active),s.addClass(g.active)):e.ctrlKey?t.toggleClass(g.active):(i.removeClass(g.active),t.addClass(g.active)),m.onLabelSelect.apply(this,n.filter("."+g.active))}},remove:{click:function(){var e=G(this).parent();e.hasClass(g.active)?h.remove.activeLabels():h.remove.activeLabels(e)}},test:{toggle:function(e){var t=h.is.multiple()?h.show:h.toggle;h.is.bubbledLabelClick(e)||h.is.bubbledIconClick(e)||h.determine.eventOnElement(e,t)&&e.preventDefault()},touch:function(e){h.determine.eventOnElement(e,function(){"touchstart"==e.type?h.timer=setTimeout(function(){h.hide()},m.delay.touch):"touchmove"==e.type&&clearTimeout(h.timer)}),e.stopPropagation()},hide:function(e){h.determine.eventInModule(e,h.hide)&&e.preventDefault()}},select:{mutation:function(e){h.debug("<select> modified, recreating menu"),h.is.selectMutation(e)&&(h.disconnect.selectObserver(),h.refresh(),h.setup.select(),h.set.selected(),h.observe.select())}},menu:{mutation:function(e){var t=e[0],n=t.addedNodes?G(t.addedNodes[0]):G(!1),i=t.removedNodes?G(t.removedNodes[0]):G(!1),a=n.add(i),o=a.is(w.addition)||0<a.closest(w.addition).length,s=a.is(w.message)||0<a.closest(w.message).length;o||s?(h.debug("Updating item selector cache"),h.refreshItems()):(h.debug("Menu modified, updating selector cache"),h.refresh())},mousedown:function(){M=!0},mouseup:function(){M=!1}},item:{mouseenter:function(e){var t=G(e.target),n=G(this),i=n.children(w.menu),a=n.siblings(w.item).children(w.menu),o=0<i.length;!(0<i.find(t).length)&&o&&(clearTimeout(h.itemTimer),h.itemTimer=setTimeout(function(){h.verbose("Showing sub-menu",i),G.each(a,function(){h.animate.hide(!1,G(this))}),h.animate.show(!1,i)},m.delay.show),e.preventDefault())},mouseleave:function(e){var t=G(this).children(w.menu);0<t.length&&(clearTimeout(h.itemTimer),h.itemTimer=setTimeout(function(){h.verbose("Hiding sub-menu",t),h.animate.hide(!1,t)},m.delay.hide))},click:function(e,t){var n=G(this),i=G(e?e.target:""),a=n.find(w.menu),o=h.get.choiceText(n),s=h.get.choiceValue(n,o),r=0<a.length,l=0<a.find(i).length;h.has.search()&&Z.activeElement.isEqualNode(T[0])||G(Z.activeElement).blur(),l||r&&!m.allowCategorySelection||(h.is.searchSelection()&&(m.allowAdditions&&h.remove.userAddition(),h.remove.searchTerm(),h.is.focusedOnSearch()||1==t||h.focusSearch(!0)),m.useLabels||(h.remove.filteredItem(),h.set.scrollPosition(n)),h.determine.selectAction.call(this,o,s))}},document:{keydown:function(e){var t=e.which;if(h.is.inObject(t,p)){var n=y.find(w.label),i=n.filter("."+g.active),a=(i.data(b.value),n.index(i)),o=n.length,s=0<i.length,r=1<i.length,l=0===a,c=a+1==o,u=h.is.searchSelection(),d=h.is.focusedOnSearch(),v=h.is.focused(),f=d&&0===h.get.caretPosition(!1),m=f&&0!==h.get.caretPosition(!0);if(u&&!s&&!d)return;t==p.leftArrow?!v&&!f||s?s&&(e.shiftKey?h.verbose("Adding previous label to selection"):(h.verbose("Selecting previous label"),n.removeClass(g.active)),l&&!r?i.addClass(g.active):i.prev(w.siblingLabel).addClass(g.active).end(),e.preventDefault()):(h.verbose("Selecting previous label"),n.last().addClass(g.active)):t==p.rightArrow?(v&&!s&&n.first().addClass(g.active),s&&(e.shiftKey?h.verbose("Adding next label to selection"):(h.verbose("Selecting next label"),n.removeClass(g.active)),c?u?d?n.removeClass(g.active):h.focusSearch():r?i.next(w.siblingLabel).addClass(g.active):i.addClass(g.active):i.next(w.siblingLabel).addClass(g.active),e.preventDefault())):t==p.deleteKey||t==p.backspace?s?(h.verbose("Removing active labels"),c&&u&&!d&&h.focusSearch(),i.last().next(w.siblingLabel).addClass(g.active),h.remove.activeLabels(i),e.preventDefault()):!f||m||s||t!=p.backspace||(h.verbose("Removing last label on input backspace"),i=n.last().addClass(g.active),h.remove.activeLabels(i)):i.removeClass(g.active)}}},keydown:function(e){var t=e.which;if(h.is.inObject(t,p)){var n,i=O.not(w.unselectable).filter("."+g.selected).eq(0),a=R.children("."+g.active).eq(0),o=0<i.length?i:a,s=0<o.length?o.siblings(":not(."+g.filtered+")").addBack():R.children(":not(."+g.filtered+")"),r=o.children(w.menu),l=o.closest(w.menu),c=l.hasClass(g.visible)||l.hasClass(g.animating)||0<l.parent(w.menu).length,u=0<r.length,d=0<o.length,v=0<o.not(w.unselectable).length,f=t==p.delimiter&&m.allowAdditions&&h.is.multiple();if(m.allowAdditions&&m.hideAdditions&&(t==p.enter||f)&&v&&(h.verbose("Selecting item from keyboard shortcut",o),h.event.item.click.call(o,e),h.is.searchSelection()&&h.remove.searchTerm(),h.is.multiple()&&e.preventDefault()),h.is.visible()){if((t==p.enter||f)&&(t==p.enter&&d&&u&&!m.allowCategorySelection?(h.verbose("Pressed enter on unselectable category, opening sub menu"),t=p.rightArrow):v&&(h.verbose("Selecting item from keyboard shortcut",o),h.event.item.click.call(o,e),h.is.searchSelection()&&(h.remove.searchTerm(),h.is.multiple()&&T.focus())),e.preventDefault()),d&&(t==p.leftArrow&&l[0]!==R[0]&&(h.verbose("Left key pressed, closing sub-menu"),h.animate.hide(!1,l),o.removeClass(g.selected),l.closest(w.item).addClass(g.selected),e.preventDefault()),t==p.rightArrow&&u&&(h.verbose("Right key pressed, opening sub-menu"),h.animate.show(!1,r),o.removeClass(g.selected),r.find(w.item).eq(0).addClass(g.selected),e.preventDefault())),t==p.upArrow){if(n=d&&c?o.prevAll(w.item+":not("+w.unselectable+")").eq(0):O.eq(0),s.index(n)<0)return h.verbose("Up key pressed but reached top of current menu"),void e.preventDefault();h.verbose("Up key pressed, changing active item"),o.removeClass(g.selected),n.addClass(g.selected),h.set.scrollPosition(n),m.selectOnKeydown&&h.is.single()&&h.set.selectedItem(n),e.preventDefault()}if(t==p.downArrow){if(0===(n=d&&c?n=o.nextAll(w.item+":not("+w.unselectable+")").eq(0):O.eq(0)).length)return h.verbose("Down key pressed but reached bottom of current menu"),void e.preventDefault();h.verbose("Down key pressed, changing active item"),O.removeClass(g.selected),n.addClass(g.selected),h.set.scrollPosition(n),m.selectOnKeydown&&h.is.single()&&h.set.selectedItem(n),e.preventDefault()}t==p.pageUp&&(h.scrollPage("up"),e.preventDefault()),t==p.pageDown&&(h.scrollPage("down"),e.preventDefault()),t==p.escape&&(h.verbose("Escape key pressed, closing dropdown"),h.hide())}else f&&e.preventDefault(),t!=p.downArrow||h.is.visible()||(h.verbose("Down key pressed, showing dropdown"),h.show(),e.preventDefault())}else h.has.search()||h.set.selectedLetter(String.fromCharCode(t))}},trigger:{change:function(){var e=Z.createEvent("HTMLEvents"),t=L[0];t&&(h.verbose("Triggering native change event"),e.initEvent("change",!0,!1),t.dispatchEvent(e))}},determine:{selectAction:function(e,t){h.verbose("Determining action",m.action),G.isFunction(h.action[m.action])?(h.verbose("Triggering preset action",m.action,e,t),h.action[m.action].call(z,e,t,this)):G.isFunction(m.action)?(h.verbose("Triggering user action",m.action,e,t),m.action.call(z,e,t,this)):h.error(v.action,m.action)},eventInModule:function(e,t){var n=G(e.target),i=0<n.closest(Z.documentElement).length,a=0<n.closest(y).length;return t=G.isFunction(t)?t:function(){},i&&!a?(h.verbose("Triggering event",t),t(),!0):(h.verbose("Event occurred in dropdown, canceling callback"),!1)},eventOnElement:function(e,t){var n=G(e.target),i=n.closest(w.siblingLabel),a=Z.body.contains(e.target),o=0===y.find(i).length,s=0===n.closest(R).length;return t=G.isFunction(t)?t:function(){},a&&o&&s?(h.verbose("Triggering event",t),t(),!0):(h.verbose("Event occurred in dropdown menu, canceling callback"),!1)}},action:{nothing:function(){},activate:function(e,t,n){t=t!==_?t:e,h.can.activate(G(n))&&(h.set.selected(t,G(n)),h.is.multiple()||h.hideAndClear())},select:function(e,t,n){t=t!==_?t:e,h.can.activate(G(n))&&(h.set.value(t,e,G(n)),h.is.multiple()||h.hideAndClear())},combo:function(e,t,n){t=t!==_?t:e,h.set.selected(t,G(n)),h.hideAndClear()},hide:function(e,t,n){h.set.value(t,e,G(n)),h.hideAndClear()}},get:{id:function(){return o},defaultText:function(){return y.data(b.defaultText)},defaultValue:function(){return y.data(b.defaultValue)},placeholderText:function(){return"auto"!=m.placeholder&&"string"==typeof m.placeholder?m.placeholder:y.data(b.placeholderText)||""},text:function(){return A.text()},query:function(){return G.trim(T.val())},searchWidth:function(e){return e=e!==_?e:T.val(),k.text(e),Math.ceil(k.width()+1)},selectionCount:function(){var e=h.get.values();return h.is.multiple()?Array.isArray(e)?e.length:0:""!==h.get.value()?1:0},transition:function(e){return"auto"==m.transition?h.is.upward(e)?"slide up":"slide down":m.transition},userValues:function(){var e=h.get.values();return!!e&&(e=Array.isArray(e)?e:[e],G.grep(e,function(e){return!1===h.get.item(e)}))},uniqueArray:function(n){return G.grep(n,function(e,t){return G.inArray(e,n)===t})},caretPosition:function(e){var t,n,i=T.get(0);return e&&"selectionEnd"in i?i.selectionEnd:!e&&"selectionStart"in i?i.selectionStart:Z.selection?(i.focus(),n=(t=Z.selection.createRange()).text.length,e?n:(t.moveStart("character",-i.value.length),t.text.length-n)):void 0},value:function(){var e=0<L.length?L.val():y.data(b.value),t=Array.isArray(e)&&1===e.length&&""===e[0];return e===_||t?"":e},values:function(){var e=h.get.value();return""===e?"":!h.has.selectInput()&&h.is.multiple()?"string"==typeof e?e.split(m.delimiter):"":e},remoteValues:function(){var e=h.get.values(),i=!1;return e&&("string"==typeof e&&(e=[e]),G.each(e,function(e,t){var n=h.read.remoteData(t);h.verbose("Restoring value from session data",n,t),n&&(i||(i={}),i[t]=n)})),i},choiceText:function(e,t){if(t=t!==_?t:m.preserveHTML,e)return 0<e.find(w.menu).length&&(h.verbose("Retrieving text of element with sub-menu"),(e=e.clone()).find(w.menu).remove(),e.find(w.menuIcon).remove()),e.data(b.text)!==_?e.data(b.text):t?G.trim(e.html()):G.trim(e.text())},choiceValue:function(e,t){return t=t||h.get.choiceText(e),!!e&&(e.data(b.value)!==_?String(e.data(b.value)):"string"==typeof t?G.trim(t.toLowerCase()):String(t))},inputEvent:function(){var e=T[0];return!!e&&(e.oninput!==_?"input":e.onpropertychange!==_?"propertychange":"keyup")},selectValues:function(){var a={values:[]};return y.find("option").each(function(){var e=G(this),t=e.html(),n=e.attr("disabled"),i=e.attr("value")!==_?e.attr("value"):t;"auto"===m.placeholder&&""===i?a.placeholder=t:a.values.push({name:t,value:i,disabled:n})}),m.placeholder&&"auto"!==m.placeholder&&(h.debug("Setting placeholder value to",m.placeholder),a.placeholder=m.placeholder),m.sortSelect?(!0===m.sortSelect?a.values.sort(function(e,t){return e.name.localeCompare(t.name)}):"natural"===m.sortSelect?a.values.sort(function(e,t){return e.name.toLowerCase().localeCompare(t.name.toLowerCase())}):G.isFunction(m.sortSelect)&&a.values.sort(m.sortSelect),h.debug("Retrieved and sorted values from select",a)):h.debug("Retrieved values from select",a),a},activeItem:function(){return O.filter("."+g.active)},selectedItem:function(){var e=O.not(w.unselectable).filter("."+g.selected);return 0<e.length?e:O.eq(0)},itemWithAdditions:function(e){var t=h.get.item(e),n=h.create.userChoice(e);return n&&0<n.length&&(t=0<t.length?t.add(n):n),t},item:function(i,a){var e,o,s=!1;return i=i!==_?i:h.get.values()!==_?h.get.values():h.get.text(),e=o?0<i.length:i!==_&&null!==i,o=h.is.multiple()&&Array.isArray(i),a=""===i||!1===i||!0===i||(a||!1),e&&O.each(function(){var e=G(this),t=h.get.choiceText(e),n=h.get.choiceValue(e,t);if(null!==n&&n!==_)if(o)-1!==G.inArray(String(n),i)&&(s=s?s.add(e):e);else if(a){if(h.verbose("Ambiguous dropdown value using strict type check",e,i),n===i)return s=e,!0}else if(String(n)==String(i))return h.verbose("Found select item by value",n,i),s=e,!0}),s}},check:{maxSelections:function(e){return!m.maxSelections||((e=e!==_?e:h.get.selectionCount())>=m.maxSelections?(h.debug("Maximum selection count reached"),m.useLabels&&(O.addClass(g.filtered),h.add.message(c.maxSelections)),!0):(h.verbose("No longer at maximum selection count"),h.remove.message(),h.remove.filteredItem(),h.is.searchSelection()&&h.filterItems(),!1))}},restore:{defaults:function(){h.clear(),h.restore.defaultText(),h.restore.defaultValue()},defaultText:function(){var e=h.get.defaultText();e===h.get.placeholderText?(h.debug("Restoring default placeholder text",e),h.set.placeholderText(e)):(h.debug("Restoring default text",e),h.set.text(e))},placeholderText:function(){h.set.placeholderText()},defaultValue:function(){var e=h.get.defaultValue();e!==_&&(h.debug("Restoring default value",e),""!==e?(h.set.value(e),h.set.selected()):(h.remove.activeItem(),h.remove.selectedItem()))},labels:function(){m.allowAdditions&&(m.useLabels||(h.error(v.labels),m.useLabels=!0),h.debug("Restoring selected values"),h.create.userLabels()),h.check.maxSelections()},selected:function(){h.restore.values(),h.is.multiple()?(h.debug("Restoring previously selected values and labels"),h.restore.labels()):h.debug("Restoring previously selected values")},values:function(){h.set.initialLoad(),m.apiSettings&&m.saveRemoteData&&h.get.remoteValues()?h.restore.remoteValues():h.set.selected(),h.get.item()?L.removeClass(g.noselection):L.addClass(g.noselection),h.remove.initialLoad()},remoteValues:function(){var e=h.get.remoteValues();h.debug("Recreating selected from session data",e),e&&(h.is.single()?G.each(e,function(e,t){h.set.text(t)}):G.each(e,function(e,t){h.add.label(e,t)}))}},read:{remoteData:function(e){var t;if(J.Storage!==_)return(t=sessionStorage.getItem(e))!==_&&t;h.error(v.noStorage)}},save:{defaults:function(){h.save.defaultText(),h.save.placeholderText(),h.save.defaultValue()},defaultValue:function(){var e=h.get.value();h.verbose("Saving default value as",e),y.data(b.defaultValue,e)},defaultText:function(){var e=h.get.text();h.verbose("Saving default text as",e),y.data(b.defaultText,e)},placeholderText:function(){var e;!1!==m.placeholder&&A.hasClass(g.placeholder)&&(e=h.get.text(),h.verbose("Saving placeholder text as",e),y.data(b.placeholderText,e))},remoteData:function(e,t){J.Storage!==_?(h.verbose("Saving remote data to session storage",t,e),sessionStorage.setItem(t,e)):h.error(v.noStorage)}},clear:function(){h.is.multiple()&&m.useLabels?h.remove.labels():(h.remove.activeItem(),h.remove.selectedItem(),h.remove.filteredItem()),h.set.placeholderText(),h.clearValue()},clearValue:function(){h.set.value("")},scrollPage:function(e,t){var n,i,a=t||h.get.selectedItem(),o=a.closest(w.menu),s=o.outerHeight(),r=o.scrollTop(),l=O.eq(0).outerHeight(),c=Math.floor(s/l),u=(o.prop("scrollHeight"),"up"==e?r-l*c:r+l*c),d=O.not(w.unselectable);i="up"==e?d.index(a)-c:d.index(a)+c,0<(n=("up"==e?0<=i:i<d.length)?d.eq(i):"up"==e?d.first():d.last()).length&&(h.debug("Scrolling page",e,n),a.removeClass(g.selected),n.addClass(g.selected),m.selectOnKeydown&&h.is.single()&&h.set.selectedItem(n),o.scrollTop(u))},set:{filtered:function(){var e=h.is.multiple(),t=h.is.searchSelection(),n=e&&t,i=t?h.get.query():"",a="string"==typeof i&&0<i.length,o=h.get.searchWidth(),s=""!==i;e&&a&&(h.verbose("Adjusting input width",o,m.glyphWidth),T.css("width",o)),a||n&&s?(h.verbose("Hiding placeholder text"),A.addClass(g.filtered)):(!e||n&&!s)&&(h.verbose("Showing placeholder text"),A.removeClass(g.filtered))},empty:function(){y.addClass(g.empty)},loading:function(){y.addClass(g.loading)},placeholderText:function(e){e=e||h.get.placeholderText(),h.debug("Setting placeholder text",e),h.set.text(e),A.addClass(g.placeholder)},tabbable:function(){h.is.searchSelection()?(h.debug("Added tabindex to searchable dropdown"),T.val("").attr("tabindex",0),R.attr("tabindex",-1)):(h.debug("Added tabindex to dropdown"),y.attr("tabindex")===_&&(y.attr("tabindex",0),R.attr("tabindex",-1)))},initialLoad:function(){h.verbose("Setting initial load"),e=!0},activeItem:function(e){m.allowAdditions&&0<e.filter(w.addition).length?e.addClass(g.filtered):e.addClass(g.active)},partialSearch:function(e){var t=h.get.query().length;T.val(e.substr(0,t))},scrollPosition:function(e,t){var n,i,a,o,s,r;n=(e=e||h.get.selectedItem()).closest(w.menu),i=e&&0<e.length,t=t!==_&&t,e&&0<n.length&&i&&(e.position().top,n.addClass(g.loading),a=(o=n.scrollTop())-n.offset().top+e.offset().top,t||(r=o+n.height()<a+5,s=a-5<o),h.debug("Scrolling to active item",a),(t||s||r)&&n.scrollTop(a),n.removeClass(g.loading))},text:function(e){"combo"===m.action?(h.debug("Changing combo button text",e,q),m.preserveHTML?q.html(e):q.text(e)):"activate"===m.action&&(e!==h.get.placeholderText()&&A.removeClass(g.placeholder),h.debug("Changing text",e,A),A.removeClass(g.filtered),m.preserveHTML?A.html(e):A.text(e))},selectedItem:function(e){var t=h.get.choiceValue(e),n=h.get.choiceText(e,!1),i=h.get.choiceText(e,!0);h.debug("Setting user selection to item",e),h.remove.activeItem(),h.set.partialSearch(n),h.set.activeItem(e),h.set.selected(t,e),h.set.text(i)},selectedLetter:function(e){var t,n=O.filter("."+g.selected),i=0<n.length&&h.has.firstLetter(n,e),a=!1;i&&(t=n.nextAll(O).eq(0),h.has.firstLetter(t,e)&&(a=t)),a||O.each(function(){if(h.has.firstLetter(G(this),e))return a=G(this),!1}),a&&(h.verbose("Scrolling to next value with letter",e),h.set.scrollPosition(a),n.removeClass(g.selected),a.addClass(g.selected),m.selectOnKeydown&&h.is.single()&&h.set.selectedItem(a))},direction:function(e){"auto"==m.direction?(e?h.is.upward(e)&&h.remove.upward(e):h.remove.upward(),h.can.openDownward(e)?h.remove.upward(e):h.set.upward(e),h.is.leftward(e)||h.can.openRightward(e)||h.set.leftward(e)):"upward"==m.direction&&h.set.upward(e)},upward:function(e){(e||y).addClass(g.upward)},leftward:function(e){(e||R).addClass(g.leftward)},value:function(e,t,n){e===_||""===e||Array.isArray(e)&&0===e.length?L.addClass(g.noselection):L.removeClass(g.noselection);var i=h.escape.value(e),a=0<L.length,o=h.get.values(),s=e!==_?String(e):e;if(a){if(!m.allowReselection&&s==o&&(h.verbose("Skipping value update already same value",e,o),!h.is.initialLoad()))return;h.is.single()&&h.has.selectInput()&&h.can.extendSelect()&&(h.debug("Adding user option",e),h.add.optionValue(e)),h.debug("Updating input value",i,o),F=!0,L.val(i),!1===m.fireOnInit&&h.is.initialLoad()?h.debug("Input native change event ignored on initial load"):h.trigger.change(),F=!1}else h.verbose("Storing value in metadata",i,L),i!==o&&y.data(b.value,s);!1===m.fireOnInit&&h.is.initialLoad()?h.verbose("No callback on initial load",m.onChange):m.onChange.call(z,e,t,n)},active:function(){y.addClass(g.active)},multiple:function(){y.addClass(g.multiple)},visible:function(){y.addClass(g.visible)},exactly:function(e,t){h.debug("Setting selected to exact values"),h.clear(),h.set.selected(e,t)},selected:function(e,r){var l=h.is.multiple();(r=m.allowAdditions?r||h.get.itemWithAdditions(e):r||h.get.item(e))&&(h.debug("Setting selected menu item to",r),h.is.multiple()&&h.remove.searchWidth(),h.is.single()?(h.remove.activeItem(),h.remove.selectedItem()):m.useLabels&&h.remove.selectedItem(),r.each(function(){var e=G(this),t=h.get.choiceText(e),n=h.get.choiceValue(e,t),i=e.hasClass(g.filtered),a=e.hasClass(g.active),o=e.hasClass(g.addition),s=l&&1==r.length;l?!a||o?(m.apiSettings&&m.saveRemoteData&&h.save.remoteData(t,n),m.useLabels?(h.add.label(n,t,s),h.add.value(n,t,e),h.set.activeItem(e),h.filterActive(),h.select.nextAvailable(r)):(h.add.value(n,t,e),h.set.text(h.add.variables(c.count)),h.set.activeItem(e))):i||(h.debug("Selected active value, removing label"),h.remove.selected(n)):(m.apiSettings&&m.saveRemoteData&&h.save.remoteData(t,n),h.set.text(t),h.set.value(n,t,e),e.addClass(g.active).addClass(g.selected))}))}},add:{label:function(e,t,n){var i,a=h.is.searchSelection()?T:A,o=h.escape.value(e);m.ignoreCase&&(o=o.toLowerCase()),i=G("<a />").addClass(g.label).attr("data-"+b.value,o).html(f.label(o,t,m.preserveHTML,m.className)),i=m.onLabelCreate.call(i,o,t),h.has.label(e)?h.debug("User selection already exists, skipping",o):(m.label.variation&&i.addClass(m.label.variation),!0===n?(h.debug("Animating in label",i),i.addClass(g.hidden).insertBefore(a).transition(m.label.transition,m.label.duration)):(h.debug("Adding selection label",i),i.insertBefore(a)))},message:function(e){var t=R.children(w.message),n=m.templates.message(h.add.variables(e));0<t.length?t.html(n):t=G("<div/>").html(n).addClass(g.message).appendTo(R)},optionValue:function(e){var t=h.escape.value(e);0<L.find('option[value="'+h.escape.string(t)+'"]').length||(h.disconnect.selectObserver(),h.is.single()&&(h.verbose("Removing previous user addition"),L.find("option."+g.addition).remove()),G("<option/>").prop("value",t).addClass(g.addition).html(e).appendTo(L),h.verbose("Adding user addition as an <option>",e),h.observe.select())},userSuggestion:function(e){var t,n=R.children(w.addition),i=h.get.item(e),a=i&&i.not(w.addition).length,o=0<n.length;m.useLabels&&h.has.maxSelections()||(""===e||a?n.remove():(o?(n.data(b.value,e).data(b.text,e).attr("data-"+b.value,e).attr("data-"+b.text,e).removeClass(g.filtered),m.hideAdditions||(t=m.templates.addition(h.add.variables(c.addResult,e)),n.html(t)),h.verbose("Replacing user suggestion with new value",n)):((n=h.create.userChoice(e)).prependTo(R),h.verbose("Adding item choice to menu corresponding with user choice addition",n)),m.hideAdditions&&!h.is.allFiltered()||n.addClass(g.selected).siblings().removeClass(g.selected),h.refreshItems()))},variables:function(e,t){var n,i,a=-1!==e.search("{count}"),o=-1!==e.search("{maxCount}"),s=-1!==e.search("{term}");return h.verbose("Adding templated variables to message",e),a&&(n=h.get.selectionCount(),e=e.replace("{count}",n)),o&&(n=h.get.selectionCount(),e=e.replace("{maxCount}",m.maxSelections)),s&&(i=t||h.get.query(),e=e.replace("{term}",i)),e},value:function(e,t,n){var i,a=h.get.values();h.has.value(e)?h.debug("Value already selected"):""!==e?(i=Array.isArray(a)?(i=a.concat([e]),h.get.uniqueArray(i)):[e],h.has.selectInput()?h.can.extendSelect()&&(h.debug("Adding value to select",e,i,L),h.add.optionValue(e)):(i=i.join(m.delimiter),h.debug("Setting hidden input to delimited value",i,L)),!1===m.fireOnInit&&h.is.initialLoad()?h.verbose("Skipping onadd callback on initial load",m.onAdd):m.onAdd.call(z,e,t,n),h.set.value(i,e,t,n),h.check.maxSelections()):h.debug("Cannot select blank values from multiselect")}},remove:{active:function(){y.removeClass(g.active)},activeLabel:function(){y.find(w.label).removeClass(g.active)},empty:function(){y.removeClass(g.empty)},loading:function(){y.removeClass(g.loading)},initialLoad:function(){e=!1},upward:function(e){(e||y).removeClass(g.upward)},leftward:function(e){(e||R).removeClass(g.leftward)},visible:function(){y.removeClass(g.visible)},activeItem:function(){O.removeClass(g.active)},filteredItem:function(){m.useLabels&&h.has.maxSelections()||(m.useLabels&&h.is.multiple()?O.not("."+g.active).removeClass(g.filtered):O.removeClass(g.filtered),m.hideDividers&&E.removeClass(g.hidden),h.remove.empty())},optionValue:function(e){var t=h.escape.value(e),n=L.find('option[value="'+h.escape.string(t)+'"]');0<n.length&&n.hasClass(g.addition)&&(s&&(s.disconnect(),h.verbose("Temporarily disconnecting mutation observer")),n.remove(),h.verbose("Removing user addition as an <option>",t),s&&s.observe(L[0],{childList:!0,subtree:!0}))},message:function(){R.children(w.message).remove()},searchWidth:function(){T.css("width","")},searchTerm:function(){h.verbose("Cleared search term"),T.val(""),h.set.filtered()},userAddition:function(){O.filter(w.addition).remove()},selected:function(e,t){if(!(t=m.allowAdditions?t||h.get.itemWithAdditions(e):t||h.get.item(e)))return!1;t.each(function(){var e=G(this),t=h.get.choiceText(e),n=h.get.choiceValue(e,t);h.is.multiple()?m.useLabels?(h.remove.value(n,t,e),h.remove.label(n)):(h.remove.value(n,t,e),0===h.get.selectionCount()?h.set.placeholderText():h.set.text(h.add.variables(c.count))):h.remove.value(n,t,e),e.removeClass(g.filtered).removeClass(g.active),m.useLabels&&e.removeClass(g.selected)})},selectedItem:function(){O.removeClass(g.selected)},value:function(e,t,n){var i,a=h.get.values();h.has.selectInput()?(h.verbose("Input is <select> removing selected option",e),i=h.remove.arrayValue(e,a),h.remove.optionValue(e)):(h.verbose("Removing from delimited values",e),i=(i=h.remove.arrayValue(e,a)).join(m.delimiter)),!1===m.fireOnInit&&h.is.initialLoad()?h.verbose("No callback on initial load",m.onRemove):m.onRemove.call(z,e,t,n),h.set.value(i,t,n),h.check.maxSelections()},arrayValue:function(t,e){return Array.isArray(e)||(e=[e]),e=G.grep(e,function(e){return t!=e}),h.verbose("Removed value from delimited string",t,e),e},label:function(e,t){var n=y.find(w.label).filter("[data-"+b.value+'="'+h.escape.string(e)+'"]');h.verbose("Removing label",n),n.remove()},activeLabels:function(e){e=e||y.find(w.label).filter("."+g.active),h.verbose("Removing active label selections",e),h.remove.labels(e)},labels:function(e){e=e||y.find(w.label),h.verbose("Removing labels",e),e.each(function(){var e=G(this),t=e.data(b.value),n=t!==_?String(t):t,i=h.is.userValue(n);!1!==m.onLabelRemove.call(e,t)?(h.remove.message(),i?(h.remove.value(n),h.remove.label(n)):h.remove.selected(n)):h.debug("Label remove callback cancelled removal")})},tabbable:function(){h.is.searchSelection()?(h.debug("Searchable dropdown initialized"),T.removeAttr("tabindex")):(h.debug("Simple selection dropdown initialized"),y.removeAttr("tabindex")),R.removeAttr("tabindex")},diacritics:function(e){return m.ignoreDiacritics?e.normalize("NFD").replace(/[\u0300-\u036f]/g,""):e}},has:{menuSearch:function(){return h.has.search()&&0<T.closest(R).length},clearItem:function(){return 0<D.length},search:function(){return 0<T.length},sizer:function(){return 0<k.length},selectInput:function(){return L.is("select")},minCharacters:function(e){return!m.minCharacters||(e=e!==_?String(e):String(h.get.query())).length>=m.minCharacters},firstLetter:function(e,t){var n;return!(!e||0===e.length||"string"!=typeof t)&&(n=h.get.choiceText(e,!1),(t=t.toLowerCase())==String(n).charAt(0).toLowerCase())},input:function(){return 0<L.length},items:function(){return 0<O.length},menu:function(){return 0<R.length},message:function(){return 0!==R.children(w.message).length},label:function(e){var t=h.escape.value(e),n=y.find(w.label);return m.ignoreCase&&(t=t.toLowerCase()),0<n.filter("[data-"+b.value+'="'+h.escape.string(t)+'"]').length},maxSelections:function(){return m.maxSelections&&h.get.selectionCount()>=m.maxSelections},allResultsFiltered:function(){var e=O.not(w.addition);return e.filter(w.unselectable).length===e.length},userSuggestion:function(){return 0<R.children(w.addition).length},query:function(){return""!==h.get.query()},value:function(e){return m.ignoreCase?h.has.valueIgnoringCase(e):h.has.valueMatchingCase(e)},valueMatchingCase:function(e){var t=h.get.values();return!!(Array.isArray(t)?t&&-1!==G.inArray(e,t):t==e)},valueIgnoringCase:function(n){var e=h.get.values(),i=!1;return Array.isArray(e)||(e=[e]),G.each(e,function(e,t){if(String(n).toLowerCase()==String(t).toLowerCase())return!(i=!0)}),i}},is:{active:function(){return y.hasClass(g.active)},animatingInward:function(){return R.transition("is inward")},animatingOutward:function(){return R.transition("is outward")},bubbledLabelClick:function(e){return G(e.target).is("select, input")&&0<y.closest("label").length},bubbledIconClick:function(e){return 0<G(e.target).closest(I).length},alreadySetup:function(){return y.is("select")&&y.parent(w.dropdown).data(C)!==_&&0===y.prev().length},animating:function(e){return e?e.transition&&e.transition("is animating"):R.transition&&R.transition("is animating")},leftward:function(e){return(e||R).hasClass(g.leftward)},clearable:function(){return y.hasClass(g.clearable)||m.clearable},disabled:function(){return y.hasClass(g.disabled)},focused:function(){return Z.activeElement===y[0]},focusedOnSearch:function(){return Z.activeElement===T[0]},allFiltered:function(){return(h.is.multiple()||h.has.search())&&!(0==m.hideAdditions&&h.has.userSuggestion())&&!h.has.message()&&h.has.allResultsFiltered()},hidden:function(e){return!h.is.visible(e)},initialLoad:function(){return e},inObject:function(n,e){var i=!1;return G.each(e,function(e,t){if(t==n)return i=!0}),i},multiple:function(){return y.hasClass(g.multiple)},remote:function(){return m.apiSettings&&h.can.useAPI()},single:function(){return!h.is.multiple()},selectMutation:function(e){var n=!1;return G.each(e,function(e,t){if(G(t.target).is("select")||G(t.addedNodes).is("select"))return!(n=!0)}),n},search:function(){return y.hasClass(g.search)},searchSelection:function(){return h.has.search()&&1===T.parent(w.dropdown).length},selection:function(){return y.hasClass(g.selection)},userValue:function(e){return-1!==G.inArray(e,h.get.userValues())},upward:function(e){return(e||y).hasClass(g.upward)},visible:function(e){return e?e.hasClass(g.visible):R.hasClass(g.visible)},verticallyScrollableContext:function(){var e=S.get(0)!==J&&S.css("overflow-y");return"auto"==e||"scroll"==e},horizontallyScrollableContext:function(){var e=S.get(0)!==J&&S.css("overflow-X");return"auto"==e||"scroll"==e}},can:{activate:function(e){return!!m.useLabels||(!h.has.maxSelections()||!(!h.has.maxSelections()||!e.hasClass(g.active)))},openDownward:function(e){var t,n,i=e||R,a=!0;return i.addClass(g.loading),n={context:{offset:S.get(0)===J?{top:0,left:0}:S.offset(),scrollTop:S.scrollTop(),height:S.outerHeight()},menu:{offset:i.offset(),height:i.outerHeight()}},h.is.verticallyScrollableContext()&&(n.menu.offset.top+=n.context.scrollTop),a=(t={above:n.context.scrollTop<=n.menu.offset.top-n.context.offset.top-n.menu.height,below:n.context.scrollTop+n.context.height>=n.menu.offset.top-n.context.offset.top+n.menu.height}).below?(h.verbose("Dropdown can fit in context downward",t),!0):t.below||t.above?(h.verbose("Dropdown cannot fit below, opening upward",t),!1):(h.verbose("Dropdown cannot fit in either direction, favoring downward",t),!0),i.removeClass(g.loading),a},openRightward:function(e){var t,n,i=e||R,a=!0;return i.addClass(g.loading),n={context:{offset:S.get(0)===J?{top:0,left:0}:S.offset(),scrollLeft:S.scrollLeft(),width:S.outerWidth()},menu:{offset:i.offset(),width:i.outerWidth()}},h.is.horizontallyScrollableContext()&&(n.menu.offset.left+=n.context.scrollLeft),(t=n.menu.offset.left-n.context.offset.left+n.menu.width>=n.context.scrollLeft+n.context.width)&&(h.verbose("Dropdown cannot fit in context rightward",t),a=!1),i.removeClass(g.loading),a},click:function(){return K||"click"==m.on},extendSelect:function(){return m.allowAdditions||m.apiSettings},show:function(){return!h.is.disabled()&&(h.has.items()||h.has.message())},useAPI:function(){return G.fn.api!==_}},animate:{show:function(e,t){var n,i=t||R,a=t?function(){}:function(){h.hideSubMenus(),h.hideOthers(),h.set.active()};e=G.isFunction(e)?e:function(){},h.verbose("Doing menu show animation",i),h.set.direction(t),n=h.get.transition(t),h.is.selection()&&h.set.scrollPosition(h.get.selectedItem(),!0),(h.is.hidden(i)||h.is.animating(i))&&("none"==n?(a(),i.transition("show"),e.call(z)):G.fn.transition!==_&&y.transition("is supported")?i.transition({animation:n+" in",debug:m.debug,verbose:m.verbose,duration:m.duration,queue:!0,onStart:a,onComplete:function(){e.call(z)}}):h.error(v.noTransition,n))},hide:function(e,t){var n=t||R,i=(t?m.duration:m.duration,t?function(){}:function(){h.can.click()&&h.unbind.intent(),h.remove.active()}),a=h.get.transition(t);e=G.isFunction(e)?e:function(){},(h.is.visible(n)||h.is.animating(n))&&(h.verbose("Doing menu hide animation",n),"none"==a?(i(),n.transition("hide"),e.call(z)):G.fn.transition!==_&&y.transition("is supported")?n.transition({animation:a+" out",duration:m.duration,debug:m.debug,verbose:m.verbose,queue:!1,onStart:i,onComplete:function(){e.call(z)}}):h.error(v.transition))}},hideAndClear:function(){h.remove.searchTerm(),h.has.maxSelections()||(h.has.search()?h.hide(function(){h.remove.filteredItem()}):h.hide())},delay:{show:function(){h.verbose("Delaying show event to ensure user intent"),clearTimeout(h.timer),h.timer=setTimeout(h.show,m.delay.show)},hide:function(){h.verbose("Delaying hide event to ensure user intent"),clearTimeout(h.timer),h.timer=setTimeout(h.hide,m.delay.hide)}},escape:{value:function(e){var t=Array.isArray(e),n="string"==typeof e,i=!n&&!t,a=n&&-1!==e.search(d.quote),o=[];return i||!a?e:(h.debug("Encoding quote values for use in select",e),t?(G.each(e,function(e,t){o.push(t.replace(d.quote,"&quot;"))}),o):e.replace(d.quote,"&quot;"))},string:function(e){return(e=String(e)).replace(d.escape,"\\$&")},htmlEntities:function(e){var t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"};return/[&<>"'`]/.test(e)?e.replace(/[&<>"'`]/g,function(e){return t[e]}):e}},setting:function(e,t){if(h.debug("Changing setting",e,t),G.isPlainObject(e))G.extend(!0,m,e);else{if(t===_)return m[e];G.isPlainObject(m[e])?G.extend(!0,m[e],t):m[e]=t}},internal:function(e,t){if(G.isPlainObject(e))G.extend(!0,h,e);else{if(t===_)return h[e];h[e]=t}},debug:function(){!m.silent&&m.debug&&(m.performance?h.performance.log(arguments):(h.debug=Function.prototype.bind.call(console.info,console,m.name+":"),h.debug.apply(console,arguments)))},verbose:function(){!m.silent&&m.verbose&&m.debug&&(m.performance?h.performance.log(arguments):(h.verbose=Function.prototype.bind.call(console.info,console,m.name+":"),h.verbose.apply(console,arguments)))},error:function(){m.silent||(h.error=Function.prototype.bind.call(console.error,console,m.name+":"),h.error.apply(console,arguments))},performance:{log:function(e){var t,n;m.performance&&(n=(t=(new Date).getTime())-(W||t),W=t,Y.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:z,"Execution Time":n})),clearTimeout(h.performance.timer),h.performance.timer=setTimeout(h.performance.display,500)},display:function(){var e=m.name+":",n=0;W=!1,clearTimeout(h.performance.timer),G.each(Y,function(e,t){n+=t["Execution Time"]}),e+=" "+n+"ms",B&&(e+=" '"+B+"'"),(console.group!==_||console.table!==_)&&0<Y.length&&(console.groupCollapsed(e),console.table?console.table(Y):G.each(Y,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),Y=[]}},invoke:function(i,e,t){var a,o,n,s=P;return e=e||X,t=z||t,"string"==typeof i&&s!==_&&(i=i.split(/[\. ]/),a=i.length-1,G.each(i,function(e,t){var n=e!=a?t+i[e+1].charAt(0).toUpperCase()+i[e+1].slice(1):i;if(G.isPlainObject(s[n])&&e!=a)s=s[n];else{if(s[n]!==_)return o=s[n],!1;if(!G.isPlainObject(s[t])||e==a)return s[t]!==_?o=s[t]:h.error(v.method,i),!1;s=s[t]}})),G.isFunction(o)?n=o.apply(t,e):o!==_&&(n=o),Array.isArray(H)?H.push(n):H!==_?H=[H,n]:n!==_&&(H=n),o}},Q?(P===_&&h.initialize(),h.invoke($)):(P!==_&&P.invoke("destroy"),h.initialize())}),H!==_?H:j},G.fn.dropdown.settings={silent:!1,debug:!1,verbose:!1,performance:!0,on:"click",action:"activate",values:!1,clearable:!1,apiSettings:!1,selectOnKeydown:!0,minCharacters:0,filterRemoteData:!1,saveRemoteData:!0,throttle:200,context:J,direction:"auto",keepOnScreen:!0,match:"both",fullTextSearch:!1,ignoreDiacritics:!1,hideDividers:!1,placeholder:"auto",preserveHTML:!0,sortSelect:!1,forceSelection:!0,allowAdditions:!1,ignoreCase:!1,hideAdditions:!0,maxSelections:!1,useLabels:!0,delimiter:",",showOnFocus:!0,allowReselection:!1,allowTab:!0,allowCategorySelection:!1,fireOnInit:!1,transition:"auto",duration:200,glyphWidth:1.037,label:{transition:"scale",duration:200,variation:!1},delay:{hide:300,show:200,search:20,touch:50},onChange:function(e,t,n){},onAdd:function(e,t,n){},onRemove:function(e,t,n){},onLabelSelect:function(e){},onLabelCreate:function(e,t){return G(this)},onLabelRemove:function(e){return!0},onNoResults:function(e){return!0},onShow:function(){},onHide:function(){},name:"Dropdown",namespace:"dropdown",message:{addResult:"Add <b>{term}</b>",count:"{count} selected",maxSelections:"Max {maxCount} selections",noResults:"No results found.",serverError:"There was an error contacting the server"},error:{action:"You called a dropdown action that was not defined",alreadySetup:"Once a select has been initialized behaviors must be called on the created ui dropdown",labels:"Allowing user additions currently requires the use of labels.",missingMultiple:"<select> requires multiple property to be set to correctly preserve multiple values",method:"The method you called is not defined.",noAPI:"The API module is required to load resources remotely",noStorage:"Saving remote data requires session storage",noTransition:"This module requires ui transitions <https://github.com/Semantic-Org/UI-Transition>",noNormalize:'"ignoreDiacritics" setting will be ignored. Browser does not support String().normalize(). You may consider including <https://cdn.jsdelivr.net/npm/unorm@1.4.1/lib/unorm.min.js> as a polyfill.'},regExp:{escape:/[-[\]{}()*+?.,\\^$|#\s:=@]/g,quote:/"/g},metadata:{defaultText:"defaultText",defaultValue:"defaultValue",placeholderText:"placeholder",text:"text",value:"value"},fields:{remoteValues:"results",values:"values",disabled:"disabled",name:"name",value:"value",text:"text",type:"type"},keys:{backspace:8,delimiter:188,deleteKey:46,enter:13,escape:27,pageUp:33,pageDown:34,leftArrow:37,upArrow:38,rightArrow:39,downArrow:40},selector:{addition:".addition",divider:".divider, .header",dropdown:".ui.dropdown",hidden:".hidden",icon:"> .dropdown.icon",input:'> input[type="hidden"], > select',item:".item",label:"> .label",remove:"> .label > .delete.icon",siblingLabel:".label",menu:".menu",message:".message",menuIcon:".dropdown.icon",search:"input.search, .menu > .search > input, .menu input.search",sizer:"> input.sizer",text:"> .text:not(.icon)",unselectable:".disabled, .filtered",clearIcon:"> .remove.icon"},className:{active:"active",addition:"addition",animating:"animating",disabled:"disabled",empty:"empty",dropdown:"ui dropdown",filtered:"filtered",hidden:"hidden transition",item:"item",label:"ui label",loading:"loading",menu:"menu",message:"message",multiple:"multiple",placeholder:"default",sizer:"sizer",search:"search",selected:"selected",selection:"selection",upward:"upward",leftward:"left",visible:"visible",clearable:"clearable",noselection:"noselection",delete:"delete"}},G.fn.dropdown.settings.templates={escape:function(e,t){if(t)return e;var n={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"};return/[&<>"'`]/.test(e)?e.replace(/[&<>"'`]/g,function(e){return n[e]}):e},dropdown:function(e,n,i){var t=e.placeholder||!1,a=e.values||[],o="",s=G.fn.dropdown.settings.templates.escape;return o+='<i class="dropdown icon"></i>',o+=t?'<div class="default text">'+s(t,n)+"</div>":'<div class="text"></div>',o+='<div class="'+i.menu+'">',G.each(a,function(e,t){o+='<div class="'+(t.disabled?i.disabled+" ":"")+i.item+'" data-value="'+String(t.value).replace(/"/g,"")+'">'+s(t.name,n)+"</div>"}),o+="</div>"},menu:function(e,o,s,r){var t=e[o.values]||[],l="",c=G.fn.dropdown.settings.templates.escape;return G.each(t,function(e,t){var n=t[o.type]?t[o.type]:"item";if("item"===n){var i=t[o.text]?' data-text="'+String(t[o.text]).replace(/"/g,"")+'"':"",a=t[o.disabled]?r.disabled+" ":"";l+='<div class="'+a+r.item+'" data-value="'+String(t[o.value]).replace(/"/g,"")+'"'+i+">",l+=c(t[o.name],s),l+="</div>"}else"header"===n&&(l+='<div class="header">',l+=c(t[o.name],s),l+="</div>")}),l},label:function(e,t,n,i){return(0,G.fn.dropdown.settings.templates.escape)(t,n)+'<i class="'+i.delete+' icon"></i>'},message:function(e){return e},addition:function(e){return e}}}(jQuery,window,document);